package com.woniu.order.controller;

import cn.hutool.core.util.ObjectUtil;
import com.woniu.common.dto.OrderDto;
import com.woniu.common.dto.OrderInquiryDto;
import com.woniu.common.utils.PageParam;
import com.woniu.common.utils.ResponseData;
import com.woniu.order.dto.PayOrderDTO;
import com.woniu.order.pojo.ZyOrder;
import com.woniu.order.service.ZyOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OrderController {
    @Autowired
    private ZyOrderService zyOrderService;
    @PostMapping("/queryAllOrder")
    public ResponseData<?> queryAllOrder(@RequestBody PageParam<OrderDto> param){
        return zyOrderService.queryAllOrder(param);
    }
    @PostMapping("/selectAllOrder")
    public ResponseData<?> selectAllOrder(@RequestBody PageParam<OrderInquiryDto> params){
        return zyOrderService.selectAllOrder(params);
    }
    @PostMapping("/selOrderDetail")
    public ResponseData<?> selOrderDetail(@RequestBody String orderId){
        String substring = orderId.substring(0, orderId.length() - 1);
        return zyOrderService.selOrderDetail(substring);
    }


    @PostMapping("/payOrder")
    public ResponseData<?> payOrder(@RequestBody PayOrderDTO payOrderDTO){
        return zyOrderService.payOrder(payOrderDTO);
    }

    @GetMapping("/queryOrderByExample")
    public ResponseData<?> queryOrderByExample(Integer state){
        return zyOrderService.queryOrderByExample(state);
    }


    @GetMapping("/queryOrderIfExist")
    Boolean queryOrderIfExist(String orderId){
        ZyOrder order = zyOrderService.getById(orderId);
        if(ObjectUtil.isEmpty(order)){
            return false;
        }else{
            return true;
        }
    }

    @GetMapping("/queryPayCustomNumber")
    public ResponseData<?> queryPayCustomNumber(){
        return zyOrderService.queryPayCustomNumber();
    }
    @GetMapping("/payMoneyNumber")
    public ResponseData<?> payMoneyNumber(){
        return zyOrderService.payMoneyNumber();
    }
    @GetMapping("/isGoingToPay")
    public ResponseData<?> isGoingToPay(){
        return zyOrderService.isGoingToPay();
    }
    @GetMapping("/isGoingToFahuo")
    public ResponseData<?> isGoingToFahuo(){
        return zyOrderService.isGoingToFahuo();
    }
    @GetMapping("/queryAllDateForEcharts")
    public ResponseData<?> queryAllDateForEcharts(){
        return zyOrderService.queryAllDateForEcharts();
    }

    @GetMapping("/queryLogisticsByOrderDetailId")
    public ResponseData<?> queryLogisticsByOrderDetailId(String orderDetailId){
        return zyOrderService.queryLogisticsByOrderDetailId(orderDetailId);
    }

    @GetMapping("/confirmOrder")
    public ResponseData<?> confirmOrder(String orderDetailId){
        return zyOrderService.confirmOrder(orderDetailId);
    }

}
